<template>
  <div>
    <div class="addShop">
      <ul>
        <li>
          <label>商品名称：</label>
          <input type="text" placeholder="请输入商品名称" v-model="addShop.proName" />
        </li>
        <li>
          <label>分类：</label>
          <input type="text" placeholder="请输入手机分类" v-model="addShop.column" />
        </li>
        <li>
          <label>品牌：</label>
          <input type="text" placeholder="请输入手机品牌" v-model="addShop.brand" />
        </li>
        <li>
          <label>LOGO：</label>
          <input type="text" placeholder="请输入手机LOGO" v-model="addShop.logo" />
        </li>
        <li>
          <label>图片：</label>
          <input type="text" placeholder="请输入手机图片" v-model="addShop.proImg" />
        </li>
        <li>
          <label>价格：</label>
          <input type="text" placeholder="请输入手机价格" v-model="addShop.price" />
        </li>
        <li>
          <label>介绍：</label>
          <input type="text" placeholder="请输入手机介绍" v-model="addShop.introduce" />
        </li>
        <li>
          <label>库存：</label>
          <input type="text" placeholder="请输入手机库存" v-model="addShop.stock" />
        </li>
        <li>
          <label>折扣：</label>
          <input type="text" placeholder="请输入手机折扣" v-model="addShop.discount" />
        </li>
        <li>
          <label>评分：</label>
          <input type="text" placeholder="请输入手机评分" v-model="addShop.score" />
        </li>
      </ul>
      <div class="buttons">
        <button style=" backgroundColor:skyblue;" @click="addShopsignOut">退出</button>
        <button style=" backgroundColor:yellow;" @click="addShopSubmit">提交</button>
      </div>
    </div>
  </div>
</template>


<script>
export default {
  name: "App",
  props: [],
  components: {},
  data() {
    return {
      addShop: {
        proName: "",
        column: "",
        brand: "",
        logo: "",
        proImg: "",
        price: "",
        introduce: "",
        stock: "",
        discount: "",
        score: ""
      }
    };
  },
  //方法 函数写这里
  methods: {
    addShopsignOut() {
      this.$router.push("/home/shop");
    },
    async addShopSubmit() {
      var addShop1 =
        this.addShop.proName !== "" &&
        this.addShop.column !== "" &&
        this.addShop.brand !== "" &&
        this.addShop.logo !== "" &&
        this.addShop.proImg !== "" &&
        this.addShop.price !== "" &&
        this.addShop.introduce !== "" &&
        this.addShop.stock !== "" &&
        this.addShop.discount !== "" &&
        this.addShop.score !== "";
      if (!addShop1) {
        return;
      }
      const res = await this.$http.post("http://127.0.0.1:3003/addShop", {
        params: this.addShop
      });
      if(res.data.code==200){
        this.$router.push("/home/shop");
      }
    }
  },
  //计算属性
  computed: {},
  //侦听器
  watch: {},
  //过滤器
  filters: {},
  //以下是生命周期
  //组件创建之前
  beforeCreate() {},
  //组件创建之后
  created() {},
  //页面渲染之前
  beforeMount() {},
  //页面渲染之后
  mounted() {},
  //页面视图数据更新之前
  beforeUpdate() {},
  //页面视图数据更新之后
  updated() {},
  //页面销毁之前
  beforeDestroy() {},
  //页面销毁之后
  destroyed() {}
};
</script>
<style lang="scss" scoped>
.addShop {
  width: 1000px;
  height: 600px;
  background-color: #fff;
  position: absolute;
  top: 50px;
  left: 200px;
  box-shadow: #ccc 0px 0px 40px;
}
.addShop ul {
  margin-top: 20px;
}

.addShop ul li {
  margin: 10px 0px;
}

.addShop ul li label {
  display: inline-block;
  font-size: 18px;
  font-weight: bold;
  width: 100px;
  height: 40px;
  margin: 0 20px;
  text-align: right;
}

.addShop ul li input {
  width: 500px;
  height: 26px;
}

.addShop .buttons {
  display: flex;
  width: 400px;
  font-size: 16px;
  justify-content: space-between;
  align-items: center;
  margin-left: 140px;
}
.addShop .buttons button {
  width: 80px;
  height: 30px;
}
</style>
